/**
 * <copyright>
 * </copyright>
 *
 */
package de.sabram.upb.specs.lido.impl;

import de.sabram.upb.specs.lido.Attr;
import de.sabram.upb.specs.lido.DepClause;
import de.sabram.upb.specs.lido.Expression;
import de.sabram.upb.specs.lido.LidoPackage;
import de.sabram.upb.specs.lido.ParamsOpt;
import de.sabram.upb.specs.lido.RemoteExpression;
import de.sabram.upb.specs.lido.RhsAttrs;
import de.sabram.upb.specs.lido.SymbolRef;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Expression</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ExpressionImpl#getDepClause <em>Dep Clause</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ExpressionImpl#getAttr <em>Attr</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ExpressionImpl#getRhsAttrs <em>Rhs Attrs</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ExpressionImpl#getName <em>Name</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ExpressionImpl#getParams <em>Params</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ExpressionImpl#getRemoteExpression <em>Remote Expression</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.ExpressionImpl#getSymbolRef <em>Symbol Ref</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ExpressionImpl extends ExpressionDepImpl implements Expression
{
  /**
   * The cached value of the '{@link #getDepClause() <em>Dep Clause</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDepClause()
   * @generated
   * @ordered
   */
  protected DepClause depClause;

  /**
   * The cached value of the '{@link #getAttr() <em>Attr</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAttr()
   * @generated
   * @ordered
   */
  protected Attr attr;

  /**
   * The cached value of the '{@link #getRhsAttrs() <em>Rhs Attrs</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRhsAttrs()
   * @generated
   * @ordered
   */
  protected RhsAttrs rhsAttrs;

  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getParams() <em>Params</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getParams()
   * @generated
   * @ordered
   */
  protected ParamsOpt params;

  /**
   * The cached value of the '{@link #getRemoteExpression() <em>Remote Expression</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRemoteExpression()
   * @generated
   * @ordered
   */
  protected RemoteExpression remoteExpression;

  /**
   * The cached value of the '{@link #getSymbolRef() <em>Symbol Ref</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSymbolRef()
   * @generated
   * @ordered
   */
  protected SymbolRef symbolRef;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ExpressionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LidoPackage.Literals.EXPRESSION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DepClause getDepClause()
  {
    return depClause;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetDepClause(DepClause newDepClause, NotificationChain msgs)
  {
    DepClause oldDepClause = depClause;
    depClause = newDepClause;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__DEP_CLAUSE, oldDepClause, newDepClause);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDepClause(DepClause newDepClause)
  {
    if (newDepClause != depClause)
    {
      NotificationChain msgs = null;
      if (depClause != null)
        msgs = ((InternalEObject)depClause).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__DEP_CLAUSE, null, msgs);
      if (newDepClause != null)
        msgs = ((InternalEObject)newDepClause).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__DEP_CLAUSE, null, msgs);
      msgs = basicSetDepClause(newDepClause, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__DEP_CLAUSE, newDepClause, newDepClause));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Attr getAttr()
  {
    return attr;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAttr(Attr newAttr, NotificationChain msgs)
  {
    Attr oldAttr = attr;
    attr = newAttr;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__ATTR, oldAttr, newAttr);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAttr(Attr newAttr)
  {
    if (newAttr != attr)
    {
      NotificationChain msgs = null;
      if (attr != null)
        msgs = ((InternalEObject)attr).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__ATTR, null, msgs);
      if (newAttr != null)
        msgs = ((InternalEObject)newAttr).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__ATTR, null, msgs);
      msgs = basicSetAttr(newAttr, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__ATTR, newAttr, newAttr));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RhsAttrs getRhsAttrs()
  {
    return rhsAttrs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRhsAttrs(RhsAttrs newRhsAttrs, NotificationChain msgs)
  {
    RhsAttrs oldRhsAttrs = rhsAttrs;
    rhsAttrs = newRhsAttrs;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__RHS_ATTRS, oldRhsAttrs, newRhsAttrs);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRhsAttrs(RhsAttrs newRhsAttrs)
  {
    if (newRhsAttrs != rhsAttrs)
    {
      NotificationChain msgs = null;
      if (rhsAttrs != null)
        msgs = ((InternalEObject)rhsAttrs).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__RHS_ATTRS, null, msgs);
      if (newRhsAttrs != null)
        msgs = ((InternalEObject)newRhsAttrs).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__RHS_ATTRS, null, msgs);
      msgs = basicSetRhsAttrs(newRhsAttrs, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__RHS_ATTRS, newRhsAttrs, newRhsAttrs));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ParamsOpt getParams()
  {
    return params;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetParams(ParamsOpt newParams, NotificationChain msgs)
  {
    ParamsOpt oldParams = params;
    params = newParams;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__PARAMS, oldParams, newParams);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setParams(ParamsOpt newParams)
  {
    if (newParams != params)
    {
      NotificationChain msgs = null;
      if (params != null)
        msgs = ((InternalEObject)params).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__PARAMS, null, msgs);
      if (newParams != null)
        msgs = ((InternalEObject)newParams).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__PARAMS, null, msgs);
      msgs = basicSetParams(newParams, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__PARAMS, newParams, newParams));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RemoteExpression getRemoteExpression()
  {
    return remoteExpression;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRemoteExpression(RemoteExpression newRemoteExpression, NotificationChain msgs)
  {
    RemoteExpression oldRemoteExpression = remoteExpression;
    remoteExpression = newRemoteExpression;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__REMOTE_EXPRESSION, oldRemoteExpression, newRemoteExpression);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRemoteExpression(RemoteExpression newRemoteExpression)
  {
    if (newRemoteExpression != remoteExpression)
    {
      NotificationChain msgs = null;
      if (remoteExpression != null)
        msgs = ((InternalEObject)remoteExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__REMOTE_EXPRESSION, null, msgs);
      if (newRemoteExpression != null)
        msgs = ((InternalEObject)newRemoteExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__REMOTE_EXPRESSION, null, msgs);
      msgs = basicSetRemoteExpression(newRemoteExpression, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__REMOTE_EXPRESSION, newRemoteExpression, newRemoteExpression));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SymbolRef getSymbolRef()
  {
    return symbolRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSymbolRef(SymbolRef newSymbolRef, NotificationChain msgs)
  {
    SymbolRef oldSymbolRef = symbolRef;
    symbolRef = newSymbolRef;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__SYMBOL_REF, oldSymbolRef, newSymbolRef);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSymbolRef(SymbolRef newSymbolRef)
  {
    if (newSymbolRef != symbolRef)
    {
      NotificationChain msgs = null;
      if (symbolRef != null)
        msgs = ((InternalEObject)symbolRef).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__SYMBOL_REF, null, msgs);
      if (newSymbolRef != null)
        msgs = ((InternalEObject)newSymbolRef).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.EXPRESSION__SYMBOL_REF, null, msgs);
      msgs = basicSetSymbolRef(newSymbolRef, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.EXPRESSION__SYMBOL_REF, newSymbolRef, newSymbolRef));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LidoPackage.EXPRESSION__DEP_CLAUSE:
        return basicSetDepClause(null, msgs);
      case LidoPackage.EXPRESSION__ATTR:
        return basicSetAttr(null, msgs);
      case LidoPackage.EXPRESSION__RHS_ATTRS:
        return basicSetRhsAttrs(null, msgs);
      case LidoPackage.EXPRESSION__PARAMS:
        return basicSetParams(null, msgs);
      case LidoPackage.EXPRESSION__REMOTE_EXPRESSION:
        return basicSetRemoteExpression(null, msgs);
      case LidoPackage.EXPRESSION__SYMBOL_REF:
        return basicSetSymbolRef(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LidoPackage.EXPRESSION__DEP_CLAUSE:
        return getDepClause();
      case LidoPackage.EXPRESSION__ATTR:
        return getAttr();
      case LidoPackage.EXPRESSION__RHS_ATTRS:
        return getRhsAttrs();
      case LidoPackage.EXPRESSION__NAME:
        return getName();
      case LidoPackage.EXPRESSION__PARAMS:
        return getParams();
      case LidoPackage.EXPRESSION__REMOTE_EXPRESSION:
        return getRemoteExpression();
      case LidoPackage.EXPRESSION__SYMBOL_REF:
        return getSymbolRef();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LidoPackage.EXPRESSION__DEP_CLAUSE:
        setDepClause((DepClause)newValue);
        return;
      case LidoPackage.EXPRESSION__ATTR:
        setAttr((Attr)newValue);
        return;
      case LidoPackage.EXPRESSION__RHS_ATTRS:
        setRhsAttrs((RhsAttrs)newValue);
        return;
      case LidoPackage.EXPRESSION__NAME:
        setName((String)newValue);
        return;
      case LidoPackage.EXPRESSION__PARAMS:
        setParams((ParamsOpt)newValue);
        return;
      case LidoPackage.EXPRESSION__REMOTE_EXPRESSION:
        setRemoteExpression((RemoteExpression)newValue);
        return;
      case LidoPackage.EXPRESSION__SYMBOL_REF:
        setSymbolRef((SymbolRef)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.EXPRESSION__DEP_CLAUSE:
        setDepClause((DepClause)null);
        return;
      case LidoPackage.EXPRESSION__ATTR:
        setAttr((Attr)null);
        return;
      case LidoPackage.EXPRESSION__RHS_ATTRS:
        setRhsAttrs((RhsAttrs)null);
        return;
      case LidoPackage.EXPRESSION__NAME:
        setName(NAME_EDEFAULT);
        return;
      case LidoPackage.EXPRESSION__PARAMS:
        setParams((ParamsOpt)null);
        return;
      case LidoPackage.EXPRESSION__REMOTE_EXPRESSION:
        setRemoteExpression((RemoteExpression)null);
        return;
      case LidoPackage.EXPRESSION__SYMBOL_REF:
        setSymbolRef((SymbolRef)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.EXPRESSION__DEP_CLAUSE:
        return depClause != null;
      case LidoPackage.EXPRESSION__ATTR:
        return attr != null;
      case LidoPackage.EXPRESSION__RHS_ATTRS:
        return rhsAttrs != null;
      case LidoPackage.EXPRESSION__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case LidoPackage.EXPRESSION__PARAMS:
        return params != null;
      case LidoPackage.EXPRESSION__REMOTE_EXPRESSION:
        return remoteExpression != null;
      case LidoPackage.EXPRESSION__SYMBOL_REF:
        return symbolRef != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //ExpressionImpl
